package com.neusoft.zygh.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;


/**
 * SpringMVC个性化配置
 */
@SuppressWarnings("deprecation")
@Configuration
public class MyWebAppConfiguration extends WebMvcConfigurerAdapter{
	//读取配置文件
	@Value(value = "${uploadPath}")
	private String uploadPath;
	
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		/**
		 * 读取本地文件
		 */
		//指定“/pic/**”定向到本地路径
		registry.addResourceHandler("/pic/**").addResourceLocations("file:"+uploadPath);
		
		//自定义静态资源映射
		registry.addResourceHandler("/admin/**").addResourceLocations("classpath:/static/admin/");
		registry.addResourceHandler("/portal/**").addResourceLocations("classpath:/static/portal/");
		super.addResourceHandlers(registry);
	}
}